package com.ruoyi.tjbb.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tjbb.domain.SysTjbbTcjlbb;
import com.ruoyi.tjbb.service.ISysTjbbTcjlbbService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 停车记录Controller
 * 
 * @author ruoyi
 * @date 2023-09-26
 */
@RestController
@RequestMapping("/tjbb/xsfx/tcjlbb")
public class SysTjbbTcjlbbController extends BaseController
{
    @Autowired
    private ISysTjbbTcjlbbService sysTjbbTcjlbbService;

    /**
     * 查询停车记录列表
     */
    @PreAuthorize("@ss.hasPermi('tjbb/xsfx:tcjlbb:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysTjbbTcjlbb sysTjbbTcjlbb)
    {
        startPage();
        List<SysTjbbTcjlbb> list = sysTjbbTcjlbbService.selectSysTjbbTcjlbbList(sysTjbbTcjlbb);
        return getDataTable(list);
    }

    /**
     * 导出停车记录列表
     */
    @PreAuthorize("@ss.hasPermi('tjbb/xsfx:tcjlbb:export')")
    @Log(title = "停车记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysTjbbTcjlbb sysTjbbTcjlbb)
    {
        List<SysTjbbTcjlbb> list = sysTjbbTcjlbbService.selectSysTjbbTcjlbbList(sysTjbbTcjlbb);
        ExcelUtil<SysTjbbTcjlbb> util = new ExcelUtil<SysTjbbTcjlbb>(SysTjbbTcjlbb.class);
        util.exportExcel(response, list, "停车记录数据");
    }

    /**
     * 获取停车记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('tjbb/xsfx:tcjlbb:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysTjbbTcjlbbService.selectSysTjbbTcjlbbById(id));
    }

    /**
     * 新增停车记录
     */
    @PreAuthorize("@ss.hasPermi('tjbb/xsfx:tcjlbb:add')")
    @Log(title = "停车记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTjbbTcjlbb sysTjbbTcjlbb)
    {
        return toAjax(sysTjbbTcjlbbService.insertSysTjbbTcjlbb(sysTjbbTcjlbb));
    }

    /**
     * 修改停车记录
     */
    @PreAuthorize("@ss.hasPermi('tjbb/xsfx:tcjlbb:edit')")
    @Log(title = "停车记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTjbbTcjlbb sysTjbbTcjlbb)
    {
        return toAjax(sysTjbbTcjlbbService.updateSysTjbbTcjlbb(sysTjbbTcjlbb));
    }

    /**
     * 删除停车记录
     */
    @PreAuthorize("@ss.hasPermi('tjbb/xsfx:tcjlbb:remove')")
    @Log(title = "停车记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysTjbbTcjlbbService.deleteSysTjbbTcjlbbByIds(ids));
    }
}
